package com.icexxx.ice_browser;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

public class ColorManager {
    private static int[] colors = { /*-16777216,*/ -16711809, -8421377, -33024, -16777089, -16711681, -8388864, -32897,
            -16776961, -8454144, -8388737, -32769, -16744704, -8454017, -8388609, -256, -16744577, -8453889, -65536,
            -129, -16744449, -8421632, -65409, -1, -16711936, -8421505, -65281 };

    public static Color getFirstColor() {
        int rgb = colors[0];
        return new Color(rgb);
    }

    public static Color getLastColor() {
        int rgb = colors[colors.length - 1];
        return new Color(rgb);
    }

    public static Color getPrevColor(Color color) {
        int rgbParam = color.getRGB();
        int rgb = colors[0];
        if (rgbParam == rgb) {
            return null;
        }
        for (int i = 0; i < colors.length; i++) {
            int rgbCur = colors[i];
            if (rgbParam == rgbCur) {
                return new Color(colors[i - 1]);
            }
        }
        return null;
    }

    public static Color getNextColor(Color color) {
        int rgbParam = color.getRGB();
        int rgb = colors[colors.length - 1];
        if (rgbParam == rgb) {
            return null;
        }
        for (int i = 0; i < colors.length; i++) {
            int rgbCur = colors[i];
            if (rgbParam == rgbCur) {
                return new Color(colors[i + 1]);
            }
        }
        return null;
    }

    public static List<Color> getAllColor() {
        List<Color> list = new ArrayList<>();
        for (int i = 0; i < colors.length; i++) {
            int rgb = colors[i];
            Color color = new Color(rgb);
            list.add(color);
        }
        return list;
    }

}
